package com.alipay.app.groupmeal.standard.ui.b;

import static com.alipay.app.groupmeal.standard.ui.MainActivity.mActivity;

import android.content.Context;
import android.view.Display;
import android.view.KeyEvent;
import android.widget.ImageView;
import android.widget.TextView;

import com.alipay.app.groupmeal.standard.R;
import com.alipay.app.groupmeal.standard.base.BasePresentation;
import com.alipay.app.groupmeal.standard.constant.BaseConstant;
import com.alipay.app.groupmeal.standard.constant.ConfigConstant;
import com.alipay.app.groupmeal.standard.offline.bean.FkBean;
import com.alipay.app.groupmeal.standard.ui.c.abcp.CPayingAbcpActivity2;
import com.alipay.iot.sdk.utils.SystemUtils;

import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder;

public class SelectPayResPre extends BasePresentation {


    TextView stateTv;

    TextView amount;

    ImageView backImage;


    private TextView cardNoTv;
    private TextView nameTv;
    private TextView btyeTv;
    private TextView kyeTv;

    private CPayingAbcpActivity2 cPayingAbcpActivity2;

    public void setcPayingAbcpActivity2(CPayingAbcpActivity2 cPayingAbcpActivity2) {
        this.cPayingAbcpActivity2 = cPayingAbcpActivity2;
    }

    @Override
    public boolean onKeyEventBack(KeyEvent event) {
        if (cPayingAbcpActivity2 != null)
            cPayingAbcpActivity2.onKeyEventBack(event);
        return super.onKeyEventBack(event);
    }


    public SelectPayResPre(Context outerContext, Display display) {
        super(outerContext, display);
    }

    @Override
    protected int getLayoutId() {

        if (ConfigConstant.displayType == BaseConstant.DISPLAY_TYPE.T2) {
            return R.layout.view_presentation_result_t2;
        } else {
            return R.layout.view_presentation_result2;
        }
    }

    @Override
    protected void initView() {
        backImage = findViewById(R.id.backImage);
        stateTv = findViewById(R.id.stateTv);
        amount = findViewById(R.id.amount);

        cardNoTv = findViewById(R.id.cardNoTv);
        nameTv = findViewById(R.id.nameTv);
        btyeTv = findViewById(R.id.btyeTv);
        kyeTv = findViewById(R.id.kyeTv);
    }

    @Override
    protected void initData() {

    }

    public void showError(String msg, FkBean fkBean) {
        stateTv.setText(msg);
        backImage.setImageResource(R.mipmap.ic_err_bg);
        if (fkBean != null) {
            cardNoTv.setText("卡号：" + fkBean.getCardno());
            nameTv.setText("姓名：" + fkBean.getName());
            btyeTv.setText("补贴余额：" + fkBean.getBtye());
            kyeTv.setText("卡余额：" + fkBean.getKye());
        }
    }

    public void showSuccess(FkBean fkBean) {
        stateTv.setText("支付成功");
        cardNoTv.setText("卡号：" + fkBean.getCardno());
        nameTv.setText("姓名：" + fkBean.getName());
        btyeTv.setText("补贴余额：" + fkBean.getBtye());
        kyeTv.setText("卡余额：" + fkBean.getKye());
    }

    public TextView getAmount() {
        return amount;
    }

    public void setAmount(TextView amount) {
        this.amount = amount;
    }
}
